<!-- Dom模板 -->
<template>
  <div class="footer">
    <!-- Dom内容 -->
    <!-- 公共-导航（底部） -->
    <p class="carDataLength">
      <span>{{nums}}</span>
    </p>
    <ul>
      <router-link
        v-for="(item, index) in navDataList"
        :key="index"
        :to="item.path"
        tag="li"
        :class="$route.path === item.path ? 'is-active' : ''"
      >
        <p><i :class="item.meta.icon"></i></p>
        {{ item.meta.title }}
      </router-link>
    </ul>
  </div>
</template>

<script>
// import a from './a'; // 引入组件
export default {
  data() {
    return {
      msg: "测试",
      navDataList: [],
      nowIndex: 0,
      nums:localStorage.getItem("carLength"), // 购物车总数量
    };
  },
  // 生命周期 - 创建完成（访问当前this实例）
  created() {},
  // 生命周期 - 挂载完成（访问DOM元素）
  mounted() {
    this.filterRouter();
    console.log(this.$route.path);
  },
  // Vue方法定义
  methods: {
    //   动态过滤路由
    filterRouter() {
      this.navDataList = this.$router.options.routes.filter((navItem) => {
        return navItem.hidden !== true;
      });
    },
  },
};
</script>

<style scoped>
/* @import url(); 引入css类 */
@import url("../fonts/iconfont.css");
.footer {
  width: 100%;
  height: 3.125rem;
  box-shadow: -0.0625rem 0.3125rem 1.25rem -0.3125rem #585757;
  position: fixed;
  bottom: 0;
  left: 0;
  background-color: white;
}

ul {
  display: flex;
  justify-content: space-around;
  list-style: none;
  align-items: center;
  height: 100%;
}

ul li {
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  flex-direction: column;
}
ul li .icon {
  font-size: 1.4375rem;
}
ul li p i {
  font-size: 1.375rem;
}

.is-active {
  color: coral;
}


.carDataLength {
  display: flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  color: #fff;
  bottom: 34px;
  right: 112px;
  min-width: 16px;
  min-height: 16px;
  border-radius: 50%;
  background-color: red;
  z-index: 6;
}
.carDataLength span {
  font-size: 12px;
}
</style>